<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__ROOT__assets/js/jquery-1.9.1.min.js"></script>
    <title>Document</title>
</head>
<body>
<div>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
</div>
<script>
    //alert(document.domain)
    $(function(){
        var ws = new WebSocket("ws://127.0.0.1:7273");
        //握手监听函数
        ws.onopen=function(){
            alert('连接');
            //状态为1证明握手成功，然后把client自定义的名字发送过去
            ws.send("发送数据");
        }
        //错误返回信息函数
        ws.onerror = function(){
            console.log("error");
        };
        //监听服务器端推送的消息
        ws.onmessage = function (msg){
            console.log(msg);
        }
        //断开WebSocket连接
        ws.onclose = function(){
            ws = false;
        }
    })

</script>

</body>
</html>